#ifndef LOGRECORD_H
#define LOGRECORD_H

#include <QMainWindow>
#include<QFile>
#include <QDateTime>
#include <QDesktopServices>
#include <QUrl>
#include <QFileInfo>
#include<QTextStream>
#include <QTextCodec>
#include <QProcess>
namespace Ui {
class LogRecord;
}
// 定义日志文件路径
//QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
//QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
namespace LogRecordWorkPlace{

const QString LOG_FILE = "F:\\Graduation_project\\WorkPlace\\work-place\\Vegetable_greenhouse_control_system\\Log_File.txt";
const QString programPath = "D:\\Program Files\\Notepad--\\Notepad--.exe"; // 替换为你的软件路径

};

class LogRecord : public QMainWindow
{
    Q_OBJECT

public:
    explicit LogRecord(QWidget *parent = nullptr);
    static LogRecord* instance();
    bool writeLogRecord(QString Information,QString userName="左旭驰",QString userType="管理员");//往日志文件中写
    void openLogFileExternal(const QString &filePath=LogRecordWorkPlace::LOG_FILE);//打开日志文件
    bool writePlainTextEdit(const QString &filePath=LogRecordWorkPlace::LOG_FILE);//往PliantextEdit控件中写日志
    ~LogRecord();

private slots:
    void on_pushButtonClose_clicked();

    void on_pushButtonOpenLogFile_clicked();

private:
    Ui::LogRecord *ui;
};

#endif // LOGRECORD_H
